Skip to content

Validate metric name before removing empty labels#7253

Merged
yeya24 merged 3 commits intocortexproject:masterfrom
yeya24:validate-metric-name-separately
Feb 16, 2026
Merged

Validate metric name before removing empty labels#7253
yeya24 merged 3 commits intocortexproject:masterfrom
yeya24:validate-metric-name-separately

Conversation

@yeya24
Copy link
Contributor

@yeya24 yeya24 commented Feb 9, 2026

What this PR does:

Extract ValidateMetricName from ValidateLabels and apply its validation before removing empty label (added in #7069).

Today, if we send a series with only one empty metric name label {__name__=""}. It is validated as a 200 because the empty label will be stripped and distributor will continue when there is no label left.

However, the expected behavior is that we should return 400 in this case to reject empty metric name value. To do it, the metric name validation should happen before removing empty label values from the series.

This edge case is caught via the Prometheus compliance test suite for remote write. https://github.com/prometheus/compliance/tree/main/remotewrite

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Signed-off-by: yeya24 <benye@amazon.com>
@dosubot dosubot bot added the type/bug label Feb 9, 2026
Signed-off-by: yeya24 <benye@amazon.com>
Signed-off-by: yeya24 <benye@amazon.com>
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 11, 2026
Copy link
Member

@SungJin1212 SungJin1212 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yeya24 yeya24 merged commit 90e5dd5 into cortexproject:master Feb 16, 2026
58 of 60 checks passed
@yeya24 yeya24 deleted the validate-metric-name-separately branch February 16, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size/L type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments